﻿<UserControl x:Class="BadHabit.Factory.Controls.ProjectTabControl"
             
    x:Name="userControl"

             
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    
    xmlns:BadHabit_Factory_Controls="clr-namespace:BadHabit.Factory.Controls"
    xmlns:BadHabit_Factory_Converters="clr-namespace:BadHabit.Factory.Converters"  
    xmlns:BadHabit_Factory="clr-namespace:BadHabit.Factory"
    xmlns:BadHabit_WPFTools="clr-namespace:BadHabit.WPFTools;assembly=BadHabit.WPFTools" 
    xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
    xmlns:Factory_Core="clr-namespace:BadHabit.Factory;assembly=FactoryCore"
             
             
    xmlns:props="clr-namespace:BadHabit.Factory.Properties"
             
             
    HorizontalAlignment="Stretch"
    VerticalAlignment="Stretch"    
    Loaded="UserControl_Loaded"
    DataContextChanged="UserControl_DataContextChanged"
    SnapsToDevicePixels="True">
    
        
    <UserControl.Resources>

        <BadHabit_Factory_Converters:BaseLineConverter x:Key="BaseLineConverter"/>

        <!-- PROJECT TAB ITEM -->
        <Style x:Key="ProjectTabItemTemplate" TargetType="{x:Type TabItem}">                                    
            <Setter Property="Template">                
                
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabItem}">
                        <!--<Border BorderBrush="Azure" BorderThickness="1">-->
                            <ContentPresenter
                            
                            x:Name="ContentSite"
                            Cursor="Hand"
                            ContentSource="Header"
                            TextBlock.FontFamily="{StaticResource BasicFont}"
                            TextBlock.FontSize="{StaticResource BasicFontSize}"
                            TextBlock.Foreground="#0050B0"
                            
                            Margin="20,4,0,5"
                            Height="20"/>
                        <!--</Border>-->
                            

                            
                       
                        
                        <ControlTemplate.Triggers>
                            <Trigger SourceName="ContentSite"  Property="IsMouseOver" Value="True">
                                <Setter TargetName="ContentSite" Property="ContentPresenter.BitmapEffect">
                                    <Setter.Value>
                                        <OuterGlowBitmapEffect GlowColor="AliceBlue" GlowSize="3"/>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>                                                        
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter TargetName="ContentSite" Property="TextBlock.Foreground" Value="LightGray"/>
                            </Trigger>                                                        
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

   

    </UserControl.Resources>
    
    <Grid>              

        
        
        <TextBlock Margin="22,0,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Foreground="{StaticResource DarkTextBrush}">
            <TextBlock Text="{Binding ProjectName}"  FontSize="22" DataContext="{Binding Project.DefaultView}"/>                
            <TextBlock Text="{Binding ClientName, StringFormat='{}, {0}'}" FontSize="14" DataContext="{Binding Project.DefaultView}"/>                                
            <LineBreak/>
            <TextBlock Text="{Binding Baseline, Converter={StaticResource BaseLineConverter}}" FontSize="14" Foreground="Gray" DataContext="{Binding Project.DefaultView}"/><TextBlock Text="{Binding SprintNumber, StringFormat='{}, Sprint {0}'}" FontSize="14" Foreground="Gray" DataContext="{Binding Project[0].CurrentSprint}"/>
            <TextBlock 
                DataContext="{Binding Project[0].Status, Converter={StaticResource EnumConverter}, ConverterParameter={x:Type Factory_Core:ProjectStatus} }"
                FontStyle="Italic"
                Foreground="{StaticResource AlertValueBrush}"
                Text="{Binding ., Converter={StaticResource LocalizeConverter}, StringFormat='{}({0})'}" >
                <TextBlock.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding}" Value="PROJECT_STARTED">
                                <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                            </DataTrigger>                            
                            <DataTrigger Binding="{Binding}" Value="{x:Null}">
                                <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                            </DataTrigger>           
                        </Style.Triggers>
                    </Style>
                </TextBlock.Style>    
            </TextBlock>
        
            
        </TextBlock>

        <TabControl x:Name="tabControl"
                    Margin="0,45,10,0"
                    
                    IsEnabledChanged="tabControl_IsEnabledChanged"
                    
                    
                    
                    BorderThickness="0,3,0,0"                                                   
                    SelectionChanged="tabControl_SelectionChanged"                    
                    
                    BorderBrush="{StaticResource NormalBrush}"
                    Padding="3"
                    IsEnabled="False">
            <TabControl.Background>
                <LinearGradientBrush  StartPoint="0.5,0" EndPoint="0.5,1" PresentationOptions:Freeze="True">
                    <GradientStop Color="#EFEFEF" Offset="0"/>
                    <GradientStop Color="#FFFFFF" Offset="0.2"/>
                    <GradientStop Color="#FFFFFF" Offset="0.6"/>
                    <GradientStop Color="Transparent" Offset="1"/>
                </LinearGradientBrush>
            </TabControl.Background>
            
            
                    
            <TabItem Header="{x:Static props:Resources.Summary}" x:Name="summaryTabItem"  Style="{StaticResource ProjectTabItemTemplate}"  >              
                <BadHabit_Factory_Controls:SummaryPanel x:Name="summaryPanel" />                    
            </TabItem>
            
            <TabItem Header="{x:Static props:Resources.Team}" x:Name="teamTabItem" Style="{StaticResource ProjectTabItemTemplate}" IsEnabled="{Binding ElementName=userControl, Path=IsTabEnabled}"  >
                <BadHabit_Factory_Controls:TeamPanel x:Name="teamPanel" />
            </TabItem>
        
            <TabItem Header="{x:Static props:Resources.Backlog}" x:Name="backlogTabItem" Style="{StaticResource ProjectTabItemTemplate}" IsEnabled="{Binding ElementName=userControl, Path=IsTabEnabled}" >
                <BadHabit_Factory_Controls:BacklogPanel />                
            </TabItem>

            <TabItem Header="{x:Static props:Resources.Tasks}" x:Name="taskTabItem" Style="{StaticResource ProjectTabItemTemplate}" IsEnabled="{Binding ElementName=userControl, Path=IsTabEnabled}" IsSelected="True">
                <BadHabit_Factory_Controls:TaskPostItPanel x:Name="postItPanel" />
            </TabItem>
            
            <TabItem Header="{x:Static props:Resources.Burndown}" Style="{StaticResource ProjectTabItemTemplate}" IsEnabled="{Binding ElementName=userControl, Path=IsTabEnabled}">
                <BadHabit_Factory_Controls:BurnDownPanel />
            </TabItem>
            
            <TabItem Header="{x:Static props:Resources.Risks}" Style="{StaticResource ProjectTabItemTemplate}" IsEnabled="{Binding ElementName=userControl, Path=IsTabEnabled}">
                <BadHabit_Factory_Controls:RiskPanel />
            </TabItem>
            
            <TabItem Header="{x:Static props:Resources.Tail}" x:Name="tailTabItem" Style="{StaticResource ProjectTabItemTemplate}" IsEnabled="{Binding ElementName=userControl, Path=IsTabEnabled}">
                <BadHabit_Factory_Controls:TailPanel x:Name="tailPanel" />
            </TabItem>
            
            <TabItem Header="{x:Static props:Resources.Reports}" x:Name="reportsTabItem" Style="{StaticResource ProjectTabItemTemplate}" IsEnabled="{Binding ElementName=userControl, Path=IsTabEnabled}">
                <BadHabit_Factory_Controls:ReportsPanel x:Name="reportsPanel"  />
            </TabItem>


            <TabItem BadHabit_WPFTools:RoleChecker.RequiredVisibleRole="COMMERCIAL_GUY"
                     Header="{x:Static props:Resources.Proposal}" Style="{StaticResource ProjectTabItemTemplate}" IsEnabled="{Binding ElementName=userControl, Path=IsTabEnabled}" >
                <BadHabit_Factory_Controls:ProposalPanel  />
            </TabItem>


            <TabItem x:Name="paymentsTabItem"
                     BadHabit_WPFTools:RoleChecker.RequiredVisibleRole="COMMERCIAL_GUY"
                     Header="{x:Static props:Resources.Payments}" Style="{StaticResource ProjectTabItemTemplate}" IsEnabled="{Binding ElementName=userControl, Path=IsTabEnabled}">            
                <BadHabit_Factory_Controls:PaymentPanel  />
            </TabItem>
            
        </TabControl>       
        
        
      

        <!-- JUST SOME FANCY STUFF-->
        <StackPanel
            IsHitTestVisible="False"              
            Height="10"
           
            x:Name="selectorMark"            
            Margin="0,69,0,0"
            Width="0"                      
            VerticalAlignment="Top"
            HorizontalAlignment="Left">
            <Canvas HorizontalAlignment="Right">
                <Polygon              
                 PresentationOptions:Freeze="True"
                 x:Name="selectorArrow"
                 Fill="#EFEFEF"                                     
                 StrokeThickness="0"                   
                 Points="0,10 10,0 20,10"/>
                <Line
                    PresentationOptions:Freeze="True"
                    StrokeEndLineCap="Triangle"
                    X1="0" Y1="8" X2="10"  Y2="0" Stroke="{StaticResource NormalBrush}" StrokeThickness="3"  />
                <Line
                    PresentationOptions:Freeze="True"
                    StrokeStartLineCap="Triangle"
                    X1="10" Y1="0" X2="20"  Y2="8" Stroke="{StaticResource NormalBrush}" StrokeThickness="3"  />
            </Canvas>
            <StackPanel.Style>
                <Style>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ElementName=tabControl, Path=IsEnabled}" Value="False">
                            <Setter Property="StackPanel.Visibility" Value="Hidden"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </StackPanel.Style>
        </StackPanel>


    </Grid>
    
     
</UserControl>
